using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL {

/// <summary>
/// The UserAddressTableManager class is responsible for managing BO.UserAddressTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class UserAddressTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all UserAddressTable objects in the database.
/// </summary>
/// <returns>A list with all UserAddressTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static UserAddressTableList GetList(){
return UserAddressTableDB.GetList();
}

/// <summary>
/// Gets a single UserAddressTable from the database without its data.
/// </summary>
/// <param name="userAddressKey">The UserAddressKey of the UserAddressTable in the database.</param>
/// <returns>A UserAddressTable object when the UserAddressKey exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static UserAddressTable GetItem(int userAddressKey){
return GetItem(userAddressKey, false);
}

/// <summary>
/// Gets a single UserAddressTable from the database.
/// </summary>
/// <param name="userAddressKey">The UserAddressKey of the UserAddressTable in the database.</param>
/// <param name="getUserAddressTableRecords">Determines whether to load all associated UserAddressTable records as well.</param>
/// <returns>
/// A UserAddressTable object when the UserAddressKey exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static UserAddressTable GetItem(int userAddressKey, bool getUserAddressTableRecords){
UserAddressTable myUserAddressTable = UserAddressTableDB.GetItem(userAddressKey);
return myUserAddressTable;
}

/// <summary>
/// Saves a UserAddressTable in the database.
/// </summary>
/// <param name="myUserAddressTable">The UserAddressTable instance to save.</param>
/// <returns>The new UserAddressKey if the UserAddressTable is new in the database or the existing UserAddressKey when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static int Save(UserAddressTable myUserAddressTable){
using (TransactionScope myTransactionScope = new TransactionScope()){
int userAddressTableUserAddressKey = UserAddressTableDB.Save(myUserAddressTable);

//  Assign the UserAddressTable its new (or existing UserAddressKey).
myUserAddressTable.UserAddressKey = userAddressTableUserAddressKey;

myTransactionScope.Complete();

return userAddressTableUserAddressKey;
}
}

/// <summary>
/// Deletes a UserAddressTable from the database.
/// </summary>
/// <param name="myUserAddressTable">The UserAddressTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(UserAddressTable myUserAddressTable){
return UserAddressTableDB.Delete(myUserAddressTable.UserAddressKey);
}

#endregion

}

}
